url = '/:slug|viewlogistics-\d+.html$'
description = '订单发送邮件'
is_hidden = 0
layout = 'default'
[session]
security = "user"
redirect = "account/login"
==
use Jason\Ccshop\Controllers\Orders;
function onStart() {
    header("Content-type: text/html; charset=utf-8");
    $userid_login = $this['user']['attributes']['id'];
    $slugArr = explode('-', str_replace('.html', '', $this->param('slug')));
    $sn = $slugArr['1'];
    $o = (new Orders());
    $order = $o->orderDetail($sn);
    $userid_order = $order['attributes']['uid'];
    if($order == null){
        return redirect('/account/login.html');
    }
    if($userid_order != $userid_login){
        return redirect('/account/login.html');
    }

    if(isset($order->custom_fields['bill_no']) && $order->custom_fields['bill_no']){
        $result = $o->viewLogistics($order->custom_fields['bill_no']);
    }else{
        $result = trans('jason.ccshop::lang.userorder.no_logistics_information');
    }
    $this['has_logistics'] = is_array($result) ? 1 : 0;
    $this['bill_no'] = isset($order->custom_fields['bill_no']) ? $order->custom_fields['bill_no'] : '' ;
    $this['result'] = $result;
    $this['order'] = $order;
}
==
<div class="main-container col2-right-layout">
    <div class="main container">
        <div class="row">
            <div id="jp_jean" class="xans-element- xans-product xans-product-menupackage ">
                <div class="xans-element- xans-product xans-product-headcategory title ">
                    <p class="banner"></p>
                </div>
            </div>
            <div class="page-title clear">
                <h1>オーダー追跡</h1>
                <a href="/sendorderemail-{{ order.sn }}.html" class="icon-email2">
                    <i class="fa fa-envelope-o"></i>
                </a>
            </div>
            {% if bill_no %}
            <div class="bill_no clear">
                <p>運送会社：
                    <b>
                        {% if bill_no|trim|slice(0,2) in [16]%}
                        YDH
                        {% elseif starts_with( bill_no|trim , 'LX')%}
                        邮政小包
                        {% elseif starts_with( bill_no|trim , 'EA')%}
                        EMS国際郵便配送
                        {% elseif bill_no|trim|slice(0,1) in [1,2,3,4,5,7,8,9] and bill_no|trim|slice(0,2) not in [16] %}
                        DHL
                        {% endif %}
                    </b>
                </p>
                <p>追跡番号：<b>{{ bill_no }}</b></p>
            </div>
            {% endif %}
            <div class="bill_cont">
                {% if has_logistics %}
                    <table class="table table-bordered">
                    {% for info in result %}
                        <tr>
                            <td>{{ info.track_occur_date }}</td>
                            <td>{% if info.track_location %}【{{ info.track_location | raw }}】{% endif %}{{ info.track_description_en | raw }}</td>
                        </tr>
                    {% endfor %}    
                    </table>                
                {% else %}
                {{ result }}
                {% endif %}
            </div>
        </div>
    </div>
</div>

<style type="text/css">
.page-title{ margin-bottom: 15px; }
.page-title h1{ float: left; }
.page-title a{ float: right;}
.page-title a i{ font-size: 20px; }
.bill_no{ margin-bottom: 10px; }
.bill_no p{ font-size: 14px; }
.bill_no p:first-child{ float: left; }
.bill_no p:last-child{ float: right; }
.bill_cont{}
.bill_cont .bill_content{}
.bill_cont .bill_content td{ text-align: left; }
</style>